package com.lw.spring.service.impl;

import com.lw.spring.mapper.UserMapper;
import com.lw.spring.pojo.TbUser;
import com.lw.spring.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/3/7 15:10
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {
    private UserMapper userMapper;

    @Autowired
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public TbUser findById(Long id) {
        return userMapper.findById(id);
    }

//    @Transactional(noRollbackFor = {ArithmeticException.class}) //单独设置优先级最高
    @Override
    public void addUser(TbUser user) {
         userMapper.addUser(user);
         int i=1/0;
    }
}
